#include <vector>
#include <iostream>

struct Fragment {
    int length;
    int offset;
};

std::vector<Fragment> fragmentPacket(int packetLength, const std::vector<int>& pathMTUs) {
    std::vector<Fragment> fragments;
    int headerLength = 20;
    int dataLength = packetLength - headerLength;
    int offset = 0;

    for (int mtu : pathMTUs) {
        int maxDataLength = mtu - headerLength;
        while (dataLength > 0) {
            int fragmentLength = std::min(dataLength, maxDataLength);
            fragments.push_back({ fragmentLength + headerLength, offset });
            dataLength -= fragmentLength;
            offset += fragmentLength;
        }
    }

    return fragments;
}

int main() {
    int packetLength = 1500;
    std::vector<int> pathMTUs = { 576, 1500, 2000 };

    std::vector<Fragment> fragments = fragmentPacket(packetLength, pathMTUs);

    for (const auto& fragment : fragments) {
        std::cout << "Fragment length: " << fragment.length << ", offset: " << fragment.offset << std::endl;
    }

    return 0;
}
